library(flexdashboard)
library(plotly)
library(ggplot2)
library(tidyverse)
library(spotifyr)id <- "81f3df676d604409abfe7d3452016983"
secret <- "4dad5e4ae74e48849e41af9b3bc941c2"
Sys.setenv(SPOTIFY_CLIENT_ID = id)
Sys.setenv(SPOTIFY_CLIENT_SECRET = secret)JTNV2020 <- get_playlist_audio_features("", "37i9dQZF1ELZEbCiN09pZG?si=eace51fcd9ac4855")JTNV2020# A tibble: 100 × 61
playlist_id playlist_name playlist_img playlist_owner_… playlist_owner_…
<chr> <chr> <chr> <chr> <chr>
1 37i9dQZF1EL… Your Top Song… https://lineup… Spotify spotify
2 37i9dQZF1EL… Your Top Song… https://lineup… Spotify spotify
3 37i9dQZF1EL… Your Top Song… https://lineup… Spotify spotify
4 37i9dQZF1EL… Your Top Song… https://lineup… Spotify spotify
5 37i9dQZF1EL… Your Top Song… https://lineup… Spotify spotify
6 37i9dQZF1EL… Your Top Song… https://lineup… Spotify spotify
7 37i9dQZF1EL… Your Top Song… https://lineup… Spotify spotify
8 37i9dQZF1EL… Your Top Song… https://lineup… Spotify spotify
9 37i9dQZF1EL… Your Top Song… https://lineup… Spotify spotify
10 37i9dQZF1EL… Your Top Song… https://lineup… Spotify spotify
# … with 90 more rows, and 56 more variables: danceability <dbl>, energy <dbl>,
# key <int>, loudness <dbl>, mode <int>, speechiness <dbl>,
# acousticness <dbl>, instrumentalness <dbl>, liveness <dbl>, valence <dbl>,
# tempo <dbl>, track.id <chr>, analysis_url <chr>, time_signature <int>,
# added_at <chr>, is_local <lgl>, primary_color <lgl>, added_by.href <chr>,
# added_by.id <chr>, added_by.type <chr>, added_by.uri <chr>,
# added_by.external_urls.spotify <chr>, track.artists <list>, …
JTNV2021 <- get_playlist_audio_features("", "4uti3gC6MRxJFVu3P6Zq09?si=780acfc809e64cb1")
JTNV2021# A tibble: 100 × 61
playlist_id playlist_name playlist_img playlist_owner_… playlist_owner_…
<chr> <chr> <chr> <chr> <chr>
1 4uti3gC6MRx… JTNV2021 https://mosaic.… Noortje van der… noortjeenolaf
2 4uti3gC6MRx… JTNV2021 https://mosaic.… Noortje van der… noortjeenolaf
3 4uti3gC6MRx… JTNV2021 https://mosaic.… Noortje van der… noortjeenolaf
4 4uti3gC6MRx… JTNV2021 https://mosaic.… Noortje van der… noortjeenolaf
5 4uti3gC6MRx… JTNV2021 https://mosaic.… Noortje van der… noortjeenolaf
6 4uti3gC6MRx… JTNV2021 https://mosaic.… Noortje van der… noortjeenolaf
7 4uti3gC6MRx… JTNV2021 https://mosaic.… Noortje van der… noortjeenolaf
8 4uti3gC6MRx… JTNV2021 https://mosaic.… Noortje van der… noortjeenolaf
9 4uti3gC6MRx… JTNV2021 https://mosaic.… Noortje van der… noortjeenolaf
10 4uti3gC6MRx… JTNV2021 https://mosaic.… Noortje van der… noortjeenolaf
# … with 90 more rows, and 56 more variables: danceability <dbl>, energy <dbl>,
# key <int>, loudness <dbl>, mode <int>, speechiness <dbl>,
# acousticness <dbl>, instrumentalness <dbl>, liveness <dbl>, valence <dbl>,
# tempo <dbl>, track.id <chr>, analysis_url <chr>, time_signature <int>,
# added_at <chr>, is_local <lgl>, primary_color <lgl>, added_by.href <chr>,
# added_by.id <chr>, added_by.type <chr>, added_by.uri <chr>,
# added_by.external_urls.spotify <chr>, track.artists <list>, …
topnummers <- bind_rows(
JTNV2020 %>% mutate(category = "JTNV2020"),
JTNV2021 %>% mutate(category = "JTNV2021")
)topnummers %>%
ggplot(aes(x = energy)) + geom_histogram(binwidth = 0.1) +
facet_wrap(~category)topnummers %>%
ggplot(aes(x = category, y = energy)) +
geom_violin()topnummers %>%
ggplot(aes(x = valence, y = energy)) + geom_point() + geom_smooth()energy_valence = topnummers %>%
mutate(
mode = ifelse(mode == 0, "Minor", "Major")
) %>%
ggplot(
aes(
x = valence,
y = energy,
size = loudness,
colour = mode
)
) +
geom_point() +
geom_rug(size = 0.1) +
geom_text(
aes(
x = valence,
y = energy,
label = label
),
data =
tibble(
label = c(".", "."),
category = c("JTNV2020", "JTNV2021"),
valence = c(0.0605, 0.9600),
energy = c(0.101, 0.967)
),
colour = "black",
size = 3,
hjust = "left",
vjust = "bottom",
nudge_x = -0.05,
nudge_y = 0.02
) +
facet_wrap(~category) +
scale_x_continuous(
limits = c(0, 1),
breaks = c(0, 0.50, 1),
minor_breaks = NULL
) +
scale_y_continuous(
limits = c(0, 1),
breaks = c(0, 0.50, 1),
minor_breaks = NULL
) +
scale_colour_brewer(
type = "qual",
palette = "Paired"
) +
scale_size_continuous(
trans = "exp",
guide = "none"
) +
theme_light() +
labs(
x = "Valence",
y = "Energy",
colour = "Mode"
)
ggplotly(energy_valence)